package com.szq.yygh.hosp.controller.api;

import com.szq.yygh.common.result.Result;
import com.szq.yygh.hosp.service.HospitalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/***
 * All rights Reserved, Designed By www.jx-lab.com
 * @Title: HospitalController
 * @Description:
 * @author lixy
 * @date 2021/8/19 15:19
 * @version V1.0
 * @Copyright: www.jx-lab.com Inc. All rights reserved.
 * 注意：本内容仅限于众合景轩信息技术有限公司内部传阅，禁止外泄以及用于其他的商业目
 */
@Api("医院信息")
@RestController
@RequestMapping("/api/hosp")
public class HospitalApiController extends BaseController {

    @Autowired
    private HospitalService hospitalService;

    @ApiOperation("根据医院编码查询医院信息")
    @PostMapping("/hospital/show")
    public Result show(HttpServletRequest request){
        Map<String, Object> requestMap = getRequestMap(request);
        String hoscode = (String) requestMap.get("hoscode");
        return Result.ok(hospitalService.findByHoscode(hoscode));
    }

    @ApiOperation("保存医院信息")
    @PostMapping("/saveHospital")
    public Result saveHospital(HttpServletRequest request){
        Map<String, Object> requestMap = getRequestMap(request);
        hospitalService.saveHospital(requestMap);
        return Result.ok();
    }
}
